package cic;

import java.awt.EventQueue;

public class GUIController {

	/**
	 * @param args
	 */
	public static CustomerLoginGUI loginFrame;
	public static SystemLogGUI syslogFrame;
	public static ReportGUI report;
	public static FillFormGUI form;
	
	public static void main(String[] args) {
		syslogFrame = new SystemLogGUI();
		syslogFrame.setLocation(600, 100);
		syslogFrame.setVisible(true);
		loginFrame = new CustomerLoginGUI();
		loginFrame.setVisible(true);
	}
	
	public static void SwitchFromLoginToReport(String username){
		loginFrame.setVisible(false);
		loginFrame = null;
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ReportGUI frame = new ReportGUI("");
					frame.setVisible(true);
					GUIController.report = frame;
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
//		report = new ReportGUI(username);
//		report.setVisible(true);
	}
	
	
	public static void log(String log) {
	    syslogFrame.appendLog(log);
	}
	
	public static void showForm(String username) {
		report.setVisible(false);
		report = null;
		form = new FillFormGUI(username);
		form.setVisible(true);
	}
	
	public static void fillForm(String formMessage, String username) {
		log("User " + username + " filled the form: the message is:\n" + formMessage);
		form.setVisible(false);
		form = null;
	}
}
